[XM] Error handling cleanup
authoratse@norwich.uk.xensource.com <atse@norwich.uk.xensource.com>
Fri, 22 Sep 2006 10:37:31 +0000 (11:37 +0100)
committeratse@norwich.uk.xensource.com <atse@norwich.uk.xensource.com>
Fri, 22 Sep 2006 10:37:31 +0000 (11:37 +0100)
commitf88384ec46a059e9601f09133c107a1cc77d3477
tree736f8765074b83a76eebe244dc72541f2c07291c
parentd5de6876d097ee9bc09847fb7163c49b80f9b201
[XM] Error handling cleanup

Introducing an OptionError exception to be used by all xm subcommands
to signal an error in the arguments. "xm" will catch these and output
the appropriate error and usage message.

Detailed Changes:

main.py:
 *  Cleaned up imports and moved warning filter outside of
    import block.
 *  Converted usage parameters and description to a python
    dict rather than strings to enable better usage help
    formatting.
 *  Removed unused list_label domain command.
 *  Added cmdHelp() prints out usage message for any command
 *  Added shortHelp() prints out the default help message when
    xm is invoked with no arguments.
 *  Added longHelp() prints out long help message when invoked
    with xm --help or xm help.
 *  Added extra optional paramter to getDomains() so we can
    tell Xend not to poll devices. This will speed up xm list.
    (PENDING changes to Xend itself.)
 *  Changed all references where 'dom' actually means 'domid'
    to use the correct name.
 *  Changed 'xm list' header format to use printf formatting style.
 *  Renamed xm_subcommand to xm_importcommand so it is more
    clear what it is doing (all xm commands are subcommands!)
 *  Moved cpu_make_map() inside xm_vcpu_pin as an anonymous func.
 *  Use OptionError whenever an invalid option is detected in xm.
 *  Added proper catch and error printing for XendError and
    OptionErrors in main().

addlabel.py:
cfgbootpolicy.py:
dry-run.py:
dump-policy.py:
get-label.py:
labels.py:
loadpolicy.py:
makepolicy.py:
rmlabel.py:
resources.py:
 *  Replaced usage() with help() that is called from main.py
 *  Replaced usage() invokation with raising OptionError

opts.py:
 *  Added very simple wrap() function that behaves differently
    to textwrap.wrap()
 *  Added OptionError()
 *  Replaced the string representation of Opt, Opts to output
    a nicely formatted usage message.
 *  Changed class Opts itself will throw approriate OptionErrors.
 *  Changed set_bool to recognise 'y' and 'n' as valid input

create.py:
 *  Some whitespace and column width cleanup.
 *  throws OptionError if encounters option error.

migrate.py:
 *  Replace usage() message with the string representation of
    gopts.

sysrq.py:
 * Replace usage message with throwing OptionErrors

Signed-off-by: Alastair Tse <atse@xensource.com>
16 files changed:
tools/python/xen/xm/addlabel.py
tools/python/xen/xm/cfgbootpolicy.py
tools/python/xen/xm/console.py
tools/python/xen/xm/create.py
tools/python/xen/xm/dry-run.py
tools/python/xen/xm/dumppolicy.py
tools/python/xen/xm/getlabel.py
tools/python/xen/xm/labels.py
tools/python/xen/xm/loadpolicy.py
tools/python/xen/xm/main.py
tools/python/xen/xm/makepolicy.py
tools/python/xen/xm/migrate.py
tools/python/xen/xm/opts.py
tools/python/xen/xm/resources.py
tools/python/xen/xm/rmlabel.py
tools/python/xen/xm/sysrq.py